<% all_resources = subject_resources(profile_or_current_subject, {:scope => scope, :limit => 0, :page=> page, :sort_by=> params[:sort_by]||sort_by||"popularity"}) %>
<% all_resources.each do |resource| %>
    <%= render :partial => 'repositories/resource', :locals => { :resource => resource.object } %>
<% end %> 

<script>
  <%if request.xhr?%>
    update_pageless_state("resources", <%=all_resources.num_pages%>, <%=all_resources.current_page%>);
  <%else%>
    document.addEventListener("DOMContentLoaded", function(){  
      update_pageless_state("resources", <%=all_resources.num_pages%>, <%=all_resources.current_page%>);
    });
  <%end%> 
</script>
